class OrdersController < ApplicationController

  def index
	@processing_orders = Orders.processing_orders
	@completed_orders = Orders.completed_orders
	@cancelled_orders = Orders.cancelled_orders
  end
  
  def new
  @order = Orders.new
  end


def create
    @order = Orders.new(params[:order])
    
    if @order.save
      flash[:notice] = 'New order was successfully created.'
      redirect_to :action => "index"
    else
      render :action => "new"
    end
  end

def show
@order = Orders.find(params[:id])
end

def edit
@order = Orders.find(params[:id])
end

def update
    @order = Orders.find(params[:id])

    if @order.update_attributes(params[:order]) 
      flash[:notice] = 'Order info was updated.'
      redirect_to :action => "show", :id => params[:id]
    else
      render :action => "edit"
end
end

def destroy
@order = Orders.find(params[:id])
@order.destroy
flash[:notice] = 'Order was permanently deleted from the system.'
redirect_to :action => "index"
end
    

end
